"""
@Author  : 康帅
@Time    : 2021/7/13 16:27
@Function: lru_cache缓存
"""


from functools import lru_cache


@lru_cache(maxsize=32)
def lru(n):
    """
    lru_cache
    maxsize参数是告诉lru_cache，最多缓存最近多少个返回值
    :return:
    """
    if n < 2:
        return n
    return lru(n-1) + lru(n-2)


if __name__ == '__main__':
    print([lru(n) for n in range(51)])
    # 清理缓存
    lru.cache_clear()
